var nodeExcel = require('excel-export');
module.exports = {
    export_excel: function (data) {
        var conf = {};
        //conf.stylesXmlFile = "styles.xml";
        conf.name = "sheet1";
        conf.cols = [{
            caption: 'path',
            type: 'string',
            width: 200
        }, {
            caption: 'label',
            type: 'string',
            width: 128
        }];
        conf.rows = [
            /* ['pi', new Date(Date.UTC(2013, 4, 1)), true, 3.14],
            ["e", new Date(2012, 4, 1), false, 2.7182],
            ["M&M<>'", new Date(Date.UTC(2013, 6, 9)), false, 1.61803],
            ["null date", null, true, 1.414] */
        ];

        data.forEach(d => {
            conf.rows.push([d.path,d.label]);
        });
        var result = nodeExcel.execute(conf);
        /* res.setHeader('Content-Type', 'application/vnd.openxmlformats;charset=utf-8');
        res.setHeader("Content-Disposition", "attachment; filename=" + "dataset.xlsx");
        res.end(result, 'binary'); */
        return result;
    }
}